home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 1471 / clscmess.cls < prev    next >
Encoding:
Text File  |  1997-02-11  |  1.5 KB  |  75 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "clscMessages"
  6. Attribute VB_Creatable = False
  7. Attribute VB_Exposed = False
  8. Option Explicit
  9.  
  10. Private colData As New Collection
  11.  
  12. 'Requred property (or function)
  13. Public Property Get Item(Index) As clsMessage
  14. Set Item = colData(Index)
  15. End Property
  16.  
  17. 'Requred property (or function)
  18. Public Property Get Count()
  19. Count = colData.Count
  20. End Property
  21.  
  22. Public Sub Add(NewItem As clsMessage)
  23. colData.Add NewItem
  24. End Sub
  25. Public Sub Create(Optional Parent)
  26.  
  27. Dim rs As Recordset
  28. Dim qd As QueryDef
  29. Dim qdChildren As QueryDef
  30. Dim rsChilren As Recordset
  31. Dim i As Integer
  32. Dim lngParentID As Long
  33. Dim msgItem As clsMessage
  34.  
  35. If IsMissing(Parent) Then 'Top level
  36.     lngParentID = 0
  37.   Else
  38.     lngParentID = Parent.ID
  39. End If
  40.  
  41.     Set qd = dbMain.QueryDefs("Messages")
  42.     qd.Parameters(0) = lngParentID
  43.     Set rs = qd.OpenRecordset()
  44.     
  45.     rs.MoveLast
  46.     rs.MoveFirst
  47.     
  48.     For i = 1 To rs.RecordCount
  49.         Set msgItem = New clsMessage
  50.         
  51.         With msgItem
  52.             .Subject = rs!Subject & ""
  53.             .Sender = rs!Sender & ""
  54.             .DateSent = rs!DateSent
  55.             .Message = rs!Message
  56.             .HasChildren = rs!HasChildren
  57.             .ID = rs!MessageID
  58.         End With
  59.         
  60.         colData.Add msgItem
  61.         rs.MoveNext
  62.     Next i
  63.     
  64.     rs.Close
  65.     
  66.  
  67.     
  68.  
  69. End Sub
  70.  
  71. Private Sub Class_Initialize()
  72. If dbMain Is Nothing Then Set dbMain = DBEngine.Workspaces(0).OpenDatabase(App.Path & "\Sample")
  73. End Sub
  74.  
  75.